﻿using Microsoft.AspNetCore.Mvc;
using MiniFox.Infrastructure;
using MiniFox.Utility;
using MiniFox.Web.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MiniFox.Tasks
{
    /// <summary>
    /// 
    /// </summary>
    public class TaskController : MvcControllerBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Response<TaskItem[]> Items()
        {
            var list = TaskPool.TaskList.ToArray();
            return list.CreateResponse();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        [HttpGet]
        public Response Start([FromQuery]string name)
        {
            var response = new Response();
            
            TaskPool.StartTask(name);
            return response;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        [HttpGet]
        public Response Stop([FromQuery] string name)
        {
            var response = new Response();
            
            TaskPool.StopTask(name);
            return response;
        }
    }
}
